/*
 * Copyright 2009 XueSong Guo.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cn.webwheel.database.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * declare that the current setter method use a new name as the database table field name.<br/>
 * if the new name starts with a '.' character, then no table name will be used.<br/>
 * if the new name contains a '.' character, then table name will be the string before '.'.
 * <pre>example:
 * {@code @}Table("student")
 * public Class Student {
 *   {@code @}Column("name") // use field "student.name"
 *   public void setName(String name) ...
 *
 *   {@code @}Column(".name") // use field "name"
 *   public void setName(String name) ...
 *
 *   {@code @}Column("s.name") // use field "s.name"
 *   public void setName(String name) ...
 *
 *   {@code @}Table("abc")
 *   {@code @}Column("name") // use field "abc.name"
 *   public void setName(String name) ...
 * }
 * </pre>
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Column {
    /**
     * table column name.<br/>
     * if it starts with '.' then it means the table name will be ignored, the string after '.' will be used as the full column name.<br/>
     * otherwise if it contains '.' then it self will be used as the full column name with table name.
     * @return column name
     */
    String value();
}
